
enum OsnCallType: Int {
    case Video
    case Audio
    case Action
    
    init(rawValue: Int) {
        switch rawValue {
        case 0: self = .Video
        case 1: self = .Audio
        case 2: self = .Action
        default: self = .Video
        }
    }
}
enum OsnCallMode: Int {
    case Single
    case Multi
    
    init(rawValue: Int) {
        switch rawValue {
        case 0: self = .Single
        case 1: self = .Multi
        default: self = .Single
        }
    }
}
enum OsnCallAction: Int {
    case Invite
    case Answer
    case Reject
    case Finish
    case Stream
    case Streams
    case Cancel
    
    init(rawValue: Int) {
        switch rawValue {
        case 0: self = .Invite
        case 1: self = .Answer
        case 2: self = .Reject
        case 3: self = .Finish
        case 4: self = .Stream
        case 5: self = .Streams
        case 6: self = .Cancel
        default: self = .Invite
        }
    }
}
class OsnCallMessageContent: OsnMessageContent {
    var cid = 0
    var type = 0
    var mode = 0
    var action = 0
    var duration = 0
    var status = ""
    var url = ""
    var voiceHostUrl = ""
    var voiceBaseUrl = ""
    var user = ""
    var urls:[String] = []
    var users:[String] = []

    override init(){
        super.init()
        contentType = OsnMessageContentType.call
    }
    override func toJson() ->[String:Any] {
        var json = super.toJson()
        json["cid"] = cid
        json["type"] = type
        json["mode"] = mode
        json["action"] = action
        json["duration"] = duration
        json["status"] = status
        json["url"] = url
        json["voiceHostUrl"] = voiceHostUrl
        json["voiceBaseUrl"] = voiceBaseUrl
        json["user"] = user
        json["urls"] = urls
        json["users"] = users
        return json
    }
    static func fromJson(_ data:[String:Any]) ->OsnCallMessageContent {
        let c = OsnCallMessageContent()
        super.fromJson(c, data)
        c.cid = data["cid"] as? Int ?? 0
        c.type = data["type"] as? Int ?? 0
        c.mode = data["mode"] as? Int ?? 0
        c.action = data["action"] as? Int ?? 0
        c.duration = data["duration"] as? Int ?? 0
        c.status = data["status"] as? String ?? ""
        c.url = data["url"] as? String ?? ""
        c.voiceHostUrl = data["voiceHostUrl"] as? String ?? ""
        c.voiceBaseUrl = data["voiceBaseUrl"] as? String ?? ""
        c.user = data["user"] as? String ?? ""
        c.urls = data["urls"] as? [String] ?? []
        c.users = data["users"] as? [String] ?? []
        return c
    }
}
